<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class M_profile extends CI_Model
{
	/*
		Function that accepts a parameter $username with type string and returns $id with type int.
	*/
	function get_user_profile($username)
	{
		$sql = "SELECT * FROM employees NATURAL JOIN users WHERE username = ?";
		$query = $this->db->query($sql, array($username));
		
		return $query->num_rows() >= 1 ? $query->result() : FALSE;
	}
	
	function get_user_details($username)
	{
		$sql = "SELECT * FROM users WHERE username = ?";
		$query = $this->db->query($sql, array($username));
		
		return $query->num_rows() >= 1 ? $query->row : FALSE;
	}
	
	function update_profile($data, $id) // employees table side
	{
		$this->db->where('emp_id', $id);
		return $this->db->update('employees', $data);
	}
	
	function get_profile_column()
	{
		$result = $this->db->list_fields('profiles');
		
		unset($result['0']);
		unset($result['1']);
		//pd($result);
		return $result;
	}
}
?>